﻿//GB/Z 29014.3 ISYC 309-04e-外径切槽和切断用可转位刀片车刀

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class ISYC_309_04e_F95e
    {
        public static void ISYC_309_F95e_H(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //基本参数-------------------------------------------------------------------------------------------------
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            //赋值参数--------------------------------------------------------------------------------------------------
            double scale = 1;
            double OAL = 27.14;
            double CDX = 6.58;
            double H = 6.54;
            double HF = 5.21;
            double HBL = 8.66;
            double HBH = 1.31;
            double CUTDIA = 11.78;
            double WF = 0.36;

            //点---------------------------------------------------------------------------------------------
            //第一部分
            //轮廓
            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(v1.X - (5.3 / 8.66) * HBL, v1.Y);
            Vector2 v3 = new Vector2(v2.X + (0.52 / 8.66) * HBL, v2.Y - (1.29 / 5.21) * HF);
            Vector2 v4 = new Vector2(v1.X - (0.26 / 8.66) * HBL, v1.Y - (1.29 / 5.21) * HF);
            Vector2 v5 = new Vector2(v1.X - (4.08 / 6.58) * CDX, v1.Y + (2.04 / 5.21) * HF);
            Vector2 v6 = new Vector2(v1.X - (8.4 / 8.66) * HBL, v1.Y + (2.04 / 5.21) * HF);
            Vector2 v7 = new Vector2(v1.X - HBL, v6.Y - (1.03 / 5.21) * HF);
            Vector2 v8 = new Vector2(v1.X - OAL, v7.Y);
            Vector2 v9 = new Vector2(v8.X, v8.Y + (0.32 / 6.54) * H);
            Vector2 v10 = fun.Inters(v9, fun.Polar(v9, 0, OAL), v6, v7);
            Vector2 v11 = new Vector2(v8.X, v9.Y - H);
            Vector2 v12 = new Vector2(v11.X, v11.Y + (0.32 / 6.54) * H);
            Vector2 v13 = new Vector2(v7.X, v12.Y);
            Vector2 v14 = new Vector2(v13.X, v11.Y);
            Vector2 v15 = new Vector2(v13.X, v11.Y - (1.05 / 5.21) * HF);
            Vector2 v16 = new Vector2(v4.X - (0.12 / 8.66) * HBL, v15.Y);
            Vector2 v17 = new Vector2(v16.X, v4.Y);
            Vector2 v18 = new Vector2(v1.X - (1.31 / 6.58) * CDX, v1.Y);
            Vector2 v19 = new Vector2(v1.X - CDX, v5.Y);
            Vector2 v20 = new Vector2(v16.X - (2.95 / 8.66) * HBL, v5.Y);
            Vector2 v21 = new Vector2(v7.X - (1.4 / 8.66) * HBL, v7.Y + (2.64 / 5.21) * HF);
            Vector2 v22 = new Vector2(v13.X - (1.4 / 8.66) * HBL, v13.Y - (2.64 / 5.21) * HF);
            Vector2 v23 = fun.Inters(v14, fun.Polar(v14, 0, OAL), v16, v17);
            Vector2 v24 = new Vector2(v7.X - (2.39 / 8.66) * HBL, v7.Y - (1.01 / 5.21) * HF);

            //第二部分
            Vector2 v25 = new Vector2(v11.X, v11.Y - (13.72 / 6.54) * H);
            Vector2 v26 = new Vector2(v25.X + (26.33 / 27.14) * OAL, v25.Y);
            Vector2 v27 = new Vector2(v26.X, v26.Y + (0.24 / 6.54) * H);
            Vector2 v28 = new Vector2(v27.X + (0.87 / 27.14) * OAL, v27.Y);
            Vector2 v29 = new Vector2(v28.X, v28.Y - (0.97 / 6.54) * H);
            Vector2 v30 = new Vector2(v27.X, v29.Y);
            Vector2 v31 = new Vector2(v30.X, v30.Y + (0.24 / 6.54) * H);
            Vector2 v32 = new Vector2(v31.X - (2.97 / 27.14) * OAL, v31.Y);
            Vector2 v33 = new Vector2(v32.X, v32.Y - (1.4 / 6.54) * H);
            Vector2 v34 = new Vector2(v25.X, v33.Y);
            Vector2 v35 = new Vector2(v25.X + (18.3 / 27.14) * OAL, v25.Y);
            Vector2 v36 = new Vector2(v33.X - (5.21 / 27.14) * OAL, v33.Y);
            Vector2 v37 = new Vector2(v35.X + (0.43 / 27.14) * OAL, v35.Y);
            Vector2 v38 = fun.Inters(v37, fun.Polar(v37, -90 * pi / 180, OAL), v33, v34);
            Vector2 v39 = new Vector2(v37.X + (1.24 / 27.14) * OAL, v37.Y);
            Vector2 v40 = fun.Inters(v39, fun.Polar(v39, -90 * pi / 180, OAL), v33, v34);
            Vector2 v41 = new Vector2(v40.X + (0.73 / 27.14) * OAL, v31.Y);
            Vector2 v42 = fun.Inters(v41, fun.Polar(v41, -90 * pi / 180, OAL), v33, v34);
            Vector2 v43 = new Vector2(v39.X + (2.9 / 27.14) * OAL, v39.Y);
            Vector2 v44 = fun.Inters(v43, fun.Polar(v43, -90 * pi / 180, OAL), v31, v41);
            Vector2 v45 = new Vector2(v43.X + (2.62 / 27.14) * OAL, v43.Y);
            Vector2 v46 = fun.Inters(v45, fun.Polar(v45, -90 * pi / 180, OAL), v31, v41);
            Vector2 v47 = new Vector2(v35.X - (6.59 / 27.14) * OAL, v43.Y + (1.85 / 6.54) * H);
            Vector2 v48 = new Vector2(v47.X + (17.1 / 27.14) * OAL, v47.Y);
            Vector2 v49 = new Vector2(v48.X, v48.Y - (5.05 / 6.54) * H);
            Vector2 v50 = new Vector2(v47.X, v49.Y);
            Vector2 v51 = new Vector2(v24.X, v25.Y);
            Vector2 v52 = new Vector2(v49.X + (13.68 / 27.14) * OAL, v49.Y - (4.07 / 6.54) * H);

            //第三部分（A-A）
            Vector2 v53 = new Vector2(v9.X - (17.28 / 27.14) * OAL, v9.Y);
            Vector2 v54 = new Vector2(v53.X - (1.67 / 27.14) * OAL, v8.Y);
            Vector2 v55 = new Vector2(v54.X, v12.Y);
            Vector2 v56 = new Vector2(v53.X, v11.Y);
            Vector2 v57 = new Vector2(v53.X, v24.Y);
            Vector2 v58 = new Vector2(v56.X - (0.57 / 27.14) * OAL, v56.Y + (1.28 / 6.54) * H);
            Vector2 v59 = new Vector2(v58.X + (2.81 / 27.14) * OAL, v58.Y);
            Vector2 v60 = new Vector2(v59.X, v59.Y - (2.31 / 6.54) * H);
            Vector2 v61 = new Vector2(v58.X, v60.Y);
            Vector2 v62 = new Vector2(v61.X - (3.81 / 27.14) * OAL, v61.Y - (1.78 / 6.54) * H);
            Vector2 v63 = new Vector2(v53.X - (8.7 / 27.14) * OAL, v53.Y + (6.56 / 6.54) * H);
            Vector2 v64 = new Vector2(v63.X + (13.79 / 27.14) * OAL, v63.Y);
            Vector2 v65 = new Vector2(v64.X, v64.Y - (17.5 / 6.54) * H);
            Vector2 v66 = new Vector2(v63.X, v65.Y);
            Vector2 v67 = new Vector2(v63.X + (7 / 27.14) * OAL, v63.Y + (1.08 / 6.54) * H);

            //第四部分（B）
            Vector2 v68 = new Vector2(v66.X + (0.57 / 27.14) * OAL, v66.Y - (5.82 / 6.54) * H);
            Vector2 v69 = new Vector2(v66.X + (12.38 / 27.14) * OAL, v68.Y);
            Vector2 v70 = new Vector2(v69.X, v69.Y - (16.49 / 6.54) * H);
            Vector2 v71 = new Vector2(v68.X, v70.Y);
            Vector2 v72 = new Vector2(v68.X + (4 / 27.14) * OAL, v68.Y - (3.89 / 6.54) * H);
            Vector2 v73 = new Vector2(v72.X, v72.Y - (5.34 / 6.54) * H);
            Vector2 v74 = new Vector2(v73.X + (2.88 / 27.14) * OAL, v73.Y - (1.59 / 6.54) * H);
            Vector2 v75 = new Vector2(v74.X + (1.2 / 27.14) * OAL, v74.Y);
            Vector2 v76 = new Vector2(v75.X, v72.Y);
            Vector2 v77 = new Vector2(v75.X, v75.Y - (0.75 / 6.54) * H);
            Vector2 v78 = new Vector2(v74.X + (0.3 / 27.14) * OAL, v74.Y - (0.32 / 6.54) * H);
            Vector2 v79 = new Vector2(v78.X, v74.Y);
            Vector2 v80 = new Vector2(v68.X + (5.71 / 27.14) * OAL, v68.Y + (0.67 / 6.54) * H);

            //第五部分（C）
            Vector2 v81 = new Vector2(v70.X - (1.41 / 27.14) * OAL, v70.Y - (15.5 / 6.54) * H);
            Vector2 v82 = new Vector2(v81.X + (35.53 / 27.14) * OAL, v81.Y);
            Vector2 v83 = new Vector2(v82.X + (0.38 / 27.14) * OAL, v82.Y + WF);
            Vector2 v84 = new Vector2(v83.X + (2.18 / 27.14) * OAL, v83.Y);
            Vector2 v85 = new Vector2(v84.X, v84.Y - (2.77 / 6.54) * H);
            Vector2 v86 = new Vector2(v85.X - (2.18 / 27.14) * OAL, v85.Y);
            Vector2 v87 = new Vector2(v86.X - (0.38 / 27.14) * OAL, v86.Y + WF);
            Vector2 v88 = new Vector2(v87.X - (9.68 / 27.14) * OAL, v87.Y);
            Vector2 v89 = new Vector2(v88.X - (0.49 / 27.14) * OAL, v88.Y - (0.49 / 6.54) * H);
            Vector2 v90 = new Vector2(v89.X, v89.Y - (4.13 / 6.54) * H);
            Vector2 v91 = new Vector2(v81.X, v90.Y);
            Vector2 v92 = new Vector2(v81.X + (8.73 / 27.14) * OAL, v81.Y);
            Vector2 v93 = new Vector2(v92.X + (0.26 / 27.14) * OAL, v92.Y - (0.97 / 6.54) * H);
            Vector2 v94 = new Vector2(v81.X, v93.Y);
            Vector2 v95 = fun.Inters(v93, fun.Polar(v93, -95 * pi / 180, OAL), v91, v90);
            Vector2 v96 = new Vector2(v92.X + (1.52 / 27.14) * OAL, v92.Y);
            Vector2 v97 = fun.Inters(v96, fun.Polar(v96, -90 * pi / 180, OAL), v91, v90);
            Vector2 v98 = new Vector2(v96.X + (4.12 / 27.14) * OAL, v96.Y);
            Vector2 v99 = fun.Inters(v98, fun.Polar(v98, -90 * pi / 180, OAL), v91, v90);
            Vector2 v100 = new Vector2(v98.X + (6.73 / 27.14) * OAL, v98.Y);
            Vector2 v101 = new Vector2(v100.X, v100.Y + (0.4 / 6.54) * H);
            Vector2 v102 = new Vector2(v101.X + (1.92 / 27.14) * OAL, v101.Y);
            Vector2 v103 = fun.Inters(v102, fun.Polar(v102, -35 * pi / 180, OAL), v81, v82);
            Vector2 v104 = fun.Inters(v100, fun.Polar(v100, -90 * pi / 180, OAL), v88, fun.Polar(v88, pi, OAL));
            Vector2 v105 = new Vector2(v104.X, v104.Y - (0.4 / 6.54) * H);
            Vector2 v106 = new Vector2(v105.X + (1.92 / 27.14) * OAL, v105.Y);
            Vector2 v107 = fun.Inters(v106, fun.Polar(v106, 35 * pi / 180, OAL), v88, fun.Polar(v88, pi, OAL));
            Vector2 v108 = new Vector2(v103.X + (0.24 / 27.14) * OAL, v103.Y);
            Vector2 v109 = fun.Inters(v108, fun.Polar(v108, -90 * pi / 180, OAL), v88, fun.Polar(v88, pi, OAL));
            Vector2 v110 = new Vector2(v108.X + (8.58 / 27.14) * OAL, v108.Y);
            Vector2 v111 = fun.Inters(v110, fun.Polar(v110, -90 * pi / 180, OAL), v88, v87);
            Vector2 v112 = new Vector2(v88.X - (8.57 / 27.14) * OAL, v88.Y);
            Vector2 v113 = new Vector2(v112.X - (0.59 / 27.14) * OAL, v112.Y - (0.32 / 6.54) * H);
            Vector2 v114 = fun.Inters(v113, fun.Polar(v113, -90 * pi / 180, OAL), v90, v91);
            Vector2 v115 = new Vector2(v82.X - (0.33 / 27.14) * OAL, v82.Y);
            Vector2 v116 = fun.Inters(v115, fun.Polar(v115, -90 * pi / 180, OAL), v87, v88);
            Vector2 v117 = new Vector2(v81.X + (4.94 / 27.14) * OAL, v81.Y);
            Vector2 v118 = new Vector2(v84.X, v84.Y - fun.CalDistance(v84, v85) / 2.0);
            Vector2 v119 = new Vector2(v81.X - (3.48 / 27.14) * OAL, v84.Y + (7.33 / 6.54) * H);
            Vector2 v120 = new Vector2(v119.X + (56.07 / 27.14) * OAL, v119.Y);
            Vector2 v121 = new Vector2(v120.X, v120.Y - (18.83 / 6.54) * H);
            Vector2 v122 = new Vector2(v119.X, v121.Y);
            Vector2 v123 = new Vector2(v119.X + (27.29 / 27.14) * OAL, v119.Y + (1.07 / 6.54) * H);

            //作图部分-----------------------------------------------------------------------
            //第一部分
            //轮廓
            LwPolyline polyline1 = new LwPolyline();
            polyline1.Vertexes.Add(new LwPolylineVertex(v1));
            polyline1.Vertexes.Add(new LwPolylineVertex(v2));
            polyline1.Vertexes.Add(new LwPolylineVertex(v3));
            polyline1.Vertexes.Add(new LwPolylineVertex(v4));
            polyline1.Vertexes.Add(new LwPolylineVertex(v1));
            fun.PolyFill(dxf, polyline1, 0.3, contour);

            LwPolyline polyline2 = new LwPolyline();
            polyline2.Vertexes.Add(new LwPolylineVertex(v18));
            polyline2.Vertexes.Add(new LwPolylineVertex(v5));
            polyline2.Vertexes.Add(new LwPolylineVertex(v6));
            polyline2.Vertexes.Add(new LwPolylineVertex(v7));
            polyline2.Vertexes.Add(new LwPolylineVertex(v8));
            polyline2.Vertexes.Add(new LwPolylineVertex(v12));
            polyline2.Vertexes.Add(new LwPolylineVertex(v13));
            polyline2.Vertexes.Add(new LwPolylineVertex(v15));
            polyline2.Vertexes.Add(new LwPolylineVertex(v16));
            polyline2.Vertexes.Add(new LwPolylineVertex(v17));
            fun.PolyFill(dxf, polyline2, 0.3, contour);

            LwPolyline polyline3 = new LwPolyline();
            polyline3.Vertexes.Add(new LwPolylineVertex(v8));
            polyline3.Vertexes.Add(new LwPolylineVertex(v9));
            polyline3.Vertexes.Add(new LwPolylineVertex(v10));
            fun.PolyFill(dxf, polyline3, 0.3, contour);

            LwPolyline polyline4 = new LwPolyline();
            polyline4.Vertexes.Add(new LwPolylineVertex(v12));
            polyline4.Vertexes.Add(new LwPolylineVertex(v11));
            polyline4.Vertexes.Add(new LwPolylineVertex(v14));
            fun.PolyFill(dxf, polyline4, 0.3, contour);

            //虚线
            LwPolyline polyline5 = new LwPolyline();
            polyline5.Vertexes.Add(new LwPolylineVertex(v21));
            polyline5.Vertexes.Add(new LwPolylineVertex(v22));
            polyline5.Linetype = Linetype.Dashed;
            polyline5.LinetypeScale = 5;
            polyline5.Layer = refin;
            dxf.AddEntity(polyline5);

            LwPolyline polyline6 = new LwPolyline();
            polyline6.Vertexes.Add(new LwPolylineVertex(v14));
            polyline6.Vertexes.Add(new LwPolylineVertex(v23));
            polyline6.Linetype = Linetype.Dashed;
            polyline6.LinetypeScale = 5;
            polyline6.Layer = dimensioning;
            dxf.AddEntity(polyline6);

            Circle circle1 = new Circle(v1, CUTDIA / 2.0);
            circle1.Linetype = Linetype.Dashed;
            circle1.LinetypeScale = 5;
            circle1.Layer = refin;
            dxf.AddEntity(circle1);

            //第二部分
            //轮廓
            LwPolyline polyline7 = new LwPolyline();
            polyline7.Vertexes.Add(new LwPolylineVertex(v25));
            polyline7.Vertexes.Add(new LwPolylineVertex(v26));
            Vector2 mirror3 = new Vector2(v25.X - 1, v25.Y - fun.CalDistance(v25, v34) / 2.0);
            Vector2 mirror4 = fun.Polar(mirror3, 0 * pi / 180, OAL * 2);
            var mirrorline3 = Pus.MirrorPolyline(polyline7, mirror3, mirror4);
            fun.PolyFill(dxf, mirrorline3, 0.3, contour);

            LwPolyline polyline8 = new LwPolyline();
            polyline8.Vertexes.Add(new LwPolylineVertex(v27));
            polyline8.Vertexes.Add(new LwPolylineVertex(v28));
            polyline8.Vertexes.Add(new LwPolylineVertex(v29));
            polyline8.Vertexes.Add(new LwPolylineVertex(v30));
            polyline8.Vertexes.Add(new LwPolylineVertex(v27));
            var mirrorline4 = Pus.MirrorPolyline(polyline8, mirror3, mirror4);
            v29 = mirrorline4.Vertexes[1].Position;
            fun.PolyFill(dxf, mirrorline4, 0.3, contour);

            LwPolyline polyline9 = new LwPolyline();
            polyline9.Vertexes.Add(new LwPolylineVertex(v31));
            polyline9.Vertexes.Add(new LwPolylineVertex(v41));
            polyline9.Vertexes.Add(new LwPolylineVertex(v42));
            var mirrorline5 = Pus.MirrorPolyline(polyline9, mirror3, mirror4);
            fun.PolyFill(dxf, mirrorline5, 0.3, contour);

            LwPolyline polyline10 = new LwPolyline();
            polyline10.Vertexes.Add(new LwPolylineVertex(v32));
            polyline10.Vertexes.Add(new LwPolylineVertex(v33));
            polyline10.Vertexes.Add(new LwPolylineVertex(v34));
            polyline10.Vertexes.Add(new LwPolylineVertex(v25));
            var mirrorline6 = Pus.MirrorPolyline(polyline10, mirror3, mirror4);
            fun.PolyFill(dxf, mirrorline6, 0.3, contour);

            LwPolyline polyline11 = new LwPolyline();
            polyline11.Vertexes.Add(new LwPolylineVertex(v35));
            polyline11.Vertexes.Add(new LwPolylineVertex(v36));//0
            polyline11.Vertexes[0].Bulge = Math.Tan(-9 * pi / 180 / 4);
            var mirrorline7 = Pus.MirrorPolyline(polyline11, mirror3, mirror4);
            fun.PolyFill(dxf, mirrorline7, 0.3, contour);

            LwPolyline polyline12 = new LwPolyline();
            polyline12.Vertexes.Add(new LwPolylineVertex(v37));
            polyline12.Vertexes.Add(new LwPolylineVertex(v38));
            var mirrorline8 = Pus.MirrorPolyline(polyline12, mirror3, mirror4);
            fun.PolyFill(dxf, mirrorline8, 0.3, contour);

            LwPolyline polyline13 = new LwPolyline();
            polyline13.Vertexes.Add(new LwPolylineVertex(v39));
            polyline13.Vertexes.Add(new LwPolylineVertex(v40));
            var mirrorline9 = Pus.MirrorPolyline(polyline13, mirror3, mirror4);
            fun.PolyFill(dxf, mirrorline9, 0.3, contour);

            LwPolyline polyline14 = new LwPolyline();
            polyline14.Vertexes.Add(new LwPolylineVertex(v43));
            polyline14.Vertexes.Add(new LwPolylineVertex(v44));
            var mirrorline10 = Pus.MirrorPolyline(polyline14, mirror3, mirror4);
            fun.PolyFill(dxf, mirrorline10, 0.3, contour);

            LwPolyline polyline15 = new LwPolyline();
            polyline15.Vertexes.Add(new LwPolylineVertex(v45));
            polyline15.Vertexes.Add(new LwPolylineVertex(v46));
            var mirrorline11 = Pus.MirrorPolyline(polyline15, mirror3, mirror4);
            fun.PolyFill(dxf, mirrorline11, 0.3, contour);

            //虚线
            LwPolyline polyline16 = new LwPolyline();
            polyline16.Vertexes.Add(new LwPolylineVertex(v47));
            polyline16.Vertexes.Add(new LwPolylineVertex(v48));
            polyline16.Vertexes.Add(new LwPolylineVertex(v49));
            polyline16.Vertexes.Add(new LwPolylineVertex(v50));
            polyline16.Vertexes.Add(new LwPolylineVertex(v47));
            polyline16.Linetype = Linetype.Dashed;
            polyline16.LinetypeScale = 5;
            polyline16.Layer = refin;
            dxf.AddEntity(polyline16);

            //第三部分
            //轮廓
            LwPolyline polyline17 = new LwPolyline();
            polyline17.Vertexes.Add(new LwPolylineVertex(v53));
            polyline17.Vertexes.Add(new LwPolylineVertex(v54));
            polyline17.Vertexes.Add(new LwPolylineVertex(v55));
            polyline17.Vertexes.Add(new LwPolylineVertex(v56));
            polyline17.Vertexes.Add(new LwPolylineVertex(v53));
            fun.PolyFill(dxf, polyline17, 0.3, contour);

            //虚线
            LwPolyline polyline18 = new LwPolyline();
            polyline18.Vertexes.Add(new LwPolylineVertex(v58));
            polyline18.Vertexes.Add(new LwPolylineVertex(v59));
            polyline18.Vertexes.Add(new LwPolylineVertex(v60));
            polyline18.Vertexes.Add(new LwPolylineVertex(v61));
            polyline18.Vertexes.Add(new LwPolylineVertex(v58));
            polyline18.Linetype = Linetype.Dashed;
            polyline18.LinetypeScale = 5;
            polyline18.Layer = refin;
            dxf.AddEntity(polyline18);

            LwPolyline polyline19 = new LwPolyline();
            polyline19.Vertexes.Add(new LwPolylineVertex(v63));
            polyline19.Vertexes.Add(new LwPolylineVertex(v64));
            polyline19.Vertexes.Add(new LwPolylineVertex(v65));
            polyline19.Vertexes.Add(new LwPolylineVertex(v66));
            polyline19.Vertexes.Add(new LwPolylineVertex(v63));
            polyline19.Linetype = Linetype.Dashed;
            polyline19.LinetypeScale = 5;
            polyline19.Layer = refin;
            dxf.AddEntity(polyline19);

            LwPolyline polyline20 = new LwPolyline();
            polyline20.Vertexes.Add(new LwPolylineVertex(v9));
            polyline20.Vertexes.Add(new LwPolylineVertex(v53));
            polyline20.Linetype = Linetype.Dashed;
            polyline20.LinetypeScale = 5;
            polyline20.Layer = refin;
            dxf.AddEntity(polyline20);

            LwPolyline polyline21 = new LwPolyline();
            polyline21.Vertexes.Add(new LwPolylineVertex(v56));
            polyline21.Vertexes.Add(new LwPolylineVertex(v11));
            polyline21.Linetype = Linetype.Dashed;
            polyline21.LinetypeScale = 5;
            polyline21.Layer = refin;
            dxf.AddEntity(polyline21);

            //第四部分
            //轮廓
            LwPolyline polyline22 = new LwPolyline();
            polyline22.Vertexes.Add(new LwPolylineVertex(v72));
            polyline22.Vertexes.Add(new LwPolylineVertex(v73));
            polyline22.Vertexes.Add(new LwPolylineVertex(v74));
            polyline22.Vertexes.Add(new LwPolylineVertex(v75));
            polyline22.Vertexes.Add(new LwPolylineVertex(v76));
            Vector2 mirror1 = fun.Polar(v68, 0, fun.CalDistance(v68, v69) / 2.0);
            Vector2 mirror2 = fun.Polar(mirror1, -90 * pi / 180, OAL);
            var mirrorline1 = Pus.MirrorPolyline(polyline22, mirror1, mirror2);
            fun.PolyFill(dxf, polyline22, 0.3, contour);

            LwPolyline polyline23 = new LwPolyline();
            polyline23.Vertexes.Add(new LwPolylineVertex(v74));
            polyline23.Vertexes.Add(new LwPolylineVertex(v78));
            polyline23.Vertexes.Add(new LwPolylineVertex(v77));
            polyline23.Vertexes.Add(new LwPolylineVertex(v75));
            var mirrorline2 = Pus.MirrorPolyline(polyline23, mirror1, mirror2);
            fun.PolyFill(dxf, polyline23, 0.3, contour);

            //虚线
            LwPolyline polyline24 = new LwPolyline();
            polyline24.Vertexes.Add(new LwPolylineVertex(v68));
            polyline24.Vertexes.Add(new LwPolylineVertex(v69));
            polyline24.Vertexes.Add(new LwPolylineVertex(v70));
            polyline24.Vertexes.Add(new LwPolylineVertex(v71));
            polyline24.Vertexes.Add(new LwPolylineVertex(v68));
            polyline24.Linetype = Linetype.Dashed;
            polyline24.LinetypeScale = 5;
            polyline24.Layer = refin;
            dxf.AddEntity(polyline24);

            //第五部分
            //轮廓
            Vector2 mirror5 = fun.Polar(v81, -90 * pi / 180, fun.CalDistance(v81, v91) / 2.0);
            Vector2 mirror6 = new Vector2(v84.X, v81.Y - fun.CalDistance(v81, v91) / 2.0);

            LwPolyline polyline25 = new LwPolyline();
            polyline25.Vertexes.Add(new LwPolylineVertex(v81));
            polyline25.Vertexes.Add(new LwPolylineVertex(v82));
            polyline25.Vertexes.Add(new LwPolylineVertex(v83));
            polyline25.Vertexes.Add(new LwPolylineVertex(v84));
            polyline25.Vertexes.Add(new LwPolylineVertex(v85));
            polyline25.Vertexes.Add(new LwPolylineVertex(v86));
            polyline25.Vertexes.Add(new LwPolylineVertex(v87));
            polyline25.Vertexes.Add(new LwPolylineVertex(v88));
            polyline25.Vertexes.Add(new LwPolylineVertex(v89));
            polyline25.Vertexes.Add(new LwPolylineVertex(v90));
            polyline25.Vertexes.Add(new LwPolylineVertex(v91));
            var mirrorline12 = Pus.MirrorPolyline(polyline25, mirror5, mirror6);
            fun.PolyFill(dxf, mirrorline12, 0.3, contour);

            LwPolyline polyline26 = new LwPolyline();
            polyline26.Vertexes.Add(new LwPolylineVertex(v93));
            polyline26.Vertexes.Add(new LwPolylineVertex(v94));
            var mirrorline13 = Pus.MirrorPolyline(polyline26, mirror5, mirror6);
            fun.PolyFill(dxf, polyline26, 0.3, contour);

            LwPolyline polyline27 = new LwPolyline();
            polyline27.Vertexes.Add(new LwPolylineVertex(v92));
            polyline27.Vertexes.Add(new LwPolylineVertex(v93));
            polyline27.Vertexes.Add(new LwPolylineVertex(v95));
            var mirrorline14 = Pus.MirrorPolyline(polyline27, mirror5, mirror6);
            fun.PolyFill(dxf, polyline27, 0.3, contour);

            LwPolyline polyline28 = new LwPolyline();
            polyline28.Vertexes.Add(new LwPolylineVertex(v96));
            polyline28.Vertexes.Add(new LwPolylineVertex(v97));
            var mirrorline15 = Pus.MirrorPolyline(polyline28, mirror5, mirror6);
            fun.PolyFill(dxf, polyline28, 0.3, contour);

            LwPolyline polyline29 = new LwPolyline();
            polyline29.Vertexes.Add(new LwPolylineVertex(v98));
            polyline29.Vertexes.Add(new LwPolylineVertex(v99));
            var mirrorline16 = Pus.MirrorPolyline(polyline29, mirror5, mirror6);
            fun.PolyFill(dxf, polyline29, 0.3, contour);

            LwPolyline polyline30 = new LwPolyline();
            polyline30.Vertexes.Add(new LwPolylineVertex(v100));
            polyline30.Vertexes.Add(new LwPolylineVertex(v101));
            polyline30.Vertexes.Add(new LwPolylineVertex(v102));
            polyline30.Vertexes.Add(new LwPolylineVertex(v103));
            var mirrorline17 = Pus.MirrorPolyline(polyline30, mirror5, mirror6);
            fun.PolyFill(dxf, mirrorline17, 0.3, contour);

            LwPolyline polyline31 = new LwPolyline();
            polyline31.Vertexes.Add(new LwPolylineVertex(v104));
            polyline31.Vertexes.Add(new LwPolylineVertex(v105));
            polyline31.Vertexes.Add(new LwPolylineVertex(v106));
            polyline31.Vertexes.Add(new LwPolylineVertex(v107));
            var mirrorline18 = Pus.MirrorPolyline(polyline31, mirror5, mirror6);
            fun.PolyFill(dxf, mirrorline18, 0.3, contour);

            LwPolyline polyline32 = new LwPolyline();
            polyline32.Vertexes.Add(new LwPolylineVertex(v108));
            polyline32.Vertexes.Add(new LwPolylineVertex(v109));
            var mirrorline19 = Pus.MirrorPolyline(polyline32, mirror5, mirror6);
            fun.PolyFill(dxf, mirrorline19, 0.3, contour);

            LwPolyline polyline33 = new LwPolyline();
            polyline33.Vertexes.Add(new LwPolylineVertex(v88));
            polyline33.Vertexes.Add(new LwPolylineVertex(v112));
            polyline33.Vertexes.Add(new LwPolylineVertex(v113));
            polyline33.Vertexes.Add(new LwPolylineVertex(v114));
            var mirrorline20 = Pus.MirrorPolyline(polyline33, mirror5, mirror6);
            fun.PolyFill(dxf, mirrorline20, 0.3, contour);

            LwPolyline polyline34 = new LwPolyline();
            polyline34.Vertexes.Add(new LwPolylineVertex(v110));
            polyline34.Vertexes.Add(new LwPolylineVertex(v111));
            var mirrorline21 = Pus.MirrorPolyline(polyline34, mirror5, mirror6);
            fun.PolyFill(dxf, mirrorline21, 0.3, contour);

            LwPolyline polyline35 = new LwPolyline();
            polyline35.Vertexes.Add(new LwPolylineVertex(v115));
            polyline35.Vertexes.Add(new LwPolylineVertex(v116));
            var mirrorline22 = Pus.MirrorPolyline(polyline35, mirror5, mirror6);
            fun.PolyFill(dxf, mirrorline22, 0.3, contour);

            //虚线
            LwPolyline polyline36 = new LwPolyline();
            polyline36.Vertexes.Add(new LwPolylineVertex(v119));
            polyline36.Vertexes.Add(new LwPolylineVertex(v120));
            polyline36.Vertexes.Add(new LwPolylineVertex(v121));
            polyline36.Vertexes.Add(new LwPolylineVertex(v122));
            polyline36.Vertexes.Add(new LwPolylineVertex(v119));
            polyline36.Linetype = Linetype.Dashed;
            polyline36.LinetypeScale = 5;
            polyline36.Layer = refin;
            dxf.AddEntity(polyline36);

            //标注---------------------------------------------------------------------------
            double height = 1 * scale;
            double arrowsize = 1 * scale;
            double exline = 0.5 * scale;

            //第一部分
            //坐标系
            fun.Axis(dxf, v11, 90, 180, "Y", "Z", "PCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v24, 90, 180, "Y", "Z", "MCS", 0.2 * scale, height * 0.5, 0);

            //OAL
            fun.dimrot1(dxf, v9, v1, 0, H * 2, 0.1, height, arrowsize, exline, "OAL", "", "");

            //CDX
            fun.dimrot1(dxf, v19, v1, 0, H, 0.1, height, arrowsize, exline, "CDX", "", "");

            //HBL
            fun.dimrot1(dxf, v15, v16, 180, H, 0.1, height, arrowsize, exline, "HBL", "", "");

            //HF
            fun.dimrot1(dxf, v1, v23, -90, OAL * (8.97 / 27.14), 0.1, height, arrowsize, exline, "HF", "", "");

            //H
            fun.dimrot1(dxf, v9, v11, 90, OAL * (5.34 / 27.14), 0.1, height, arrowsize, exline, "H", "", "");

            //HBH
            fun.dimrot1(dxf, v13, v15, 90, OAL * (3.84 / 27.14), 0.1, height, arrowsize, exline, "HBH", "", "");

            //CUTDIA
            fun.dimrot1(dxf, fun.Polar(v1, 135 * pi / 180, CUTDIA / 2.0), fun.Polar(v1, -45 * pi / 180, CUTDIA / 2.0), -45, 0, 0.1, height, arrowsize, exline, "CUTDIA", "", "");

            //HTA
            Line line1 = new Line(v1, new Vector2(v1.X + OAL * (12.49 / 27.14), v1.Y));
            line1.Layer = dimensioning;
            dxf.AddEntity(line1);

            fun.jt1(dxf, new Vector2(v1.X + OAL * (11.64 / 27.14), v1.Y), -90, 5, 0, "HTA", height);
            fun.jt1(dxf, new Vector2(v1.X + OAL * (11.64 / 27.14), v1.Y), 90, 3, 0, "", height);

            fun.text1(dxf, new Vector2(v22.X, v22.Y - (2 / 6.54) * H), 90, "A");
            fun.text1(dxf, new Vector2(v21.X, v21.Y + (2 / 6.54) * H), 90, "A");

            //第二部分
            //坐标系
            fun.Axis(dxf, v25, 180, 270, "Z", "X", "PCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v51, 180, 270, "Z", "X", "MCS", 0.2 * scale, height * 0.5, 0);

            //LPR
            fun.dimrot1(dxf, v51, v29, 180, H * 2, 0.1, height, arrowsize, exline, "LPR", "", "");

            //LF
            fun.dimrot1(dxf, v34, v29, 180, H * 2.5, 0.1, height, arrowsize, exline, "LF", "", "");

            fun.jt1(dxf, v52, 180, 5, 0, "FDP", height);

            fun.text1(dxf, new Vector2(v47.X + fun.CalDistance(v47, v48) / 2.0, v47.Y + (0.86 / 6.54) * H), 90, "C");

            //第三部分
            //坐标系
            fun.Axis(dxf, v57, 90, 180, "", "", "PCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v56, 90, 180, "", "", "MCS", 0.2 * scale, height * 0.5, 0);
            fun.Axis(dxf, v62, 90, 180, "Y", "X", "", 0.2 * scale, height * 0.5, 0);

            fun.text1(dxf, v67, 90, "A-A");

            //第四部分
            //坐标系
            fun.Axis(dxf, v77, 90, 180, "Y", "X", "PCS", 0.2 * scale, height * 0.5, 0);

            fun.text1(dxf, v80, 90, "B");

            //第五部分
            //坐标系
            fun.Axis(dxf, v117, 180, 270, "Z", "X", "MCS", 0.2 * scale, height * 0.5, 0);
            v82 = mirrorline12.Vertexes[1].Position;
            v84 = mirrorline12.Vertexes[3].Position;
            v85 = mirrorline12.Vertexes[4].Position;
            v90 = mirrorline12.Vertexes[9].Position;
            v118 = new Vector2(v84.X, v84.Y + fun.CalDistance(v84, v85) / 2.0);
            fun.Axis(dxf, v118, 90, 180, "X", "Y", "CSW", 0.2 * scale, height * 0.5, 0);

            //WF
            fun.dimrot1(dxf, v84, v90, -90, OAL * (9.45 / 27.14), 0.1, height, arrowsize, exline, "WF", "", "");

            fun.text1(dxf, v123, 90, "C");

            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
